package br.com.arndroid.coupman.model;

import br.com.arndroid.lib.entity.EntityPOJO;

public class CategoryPOJO extends EntityPOJO {
	
	@Override
	public String getName() {
		return name;
	}

	public String name;
	
	public String icon_uri;
	
	@Override
	public boolean equals(Object obj) {
		if(super.equals(obj)) {
			return true;
		} else if(obj instanceof CategoryPOJO) {
			CategoryPOJO temp = (CategoryPOJO) obj;
			//_id:
			if(this._id != null) {
				if(!this._id.equals(temp._id))
					return false;
			} else {
				if(temp._id != null)
					return false;
			}

			//name:
			if(this.name != null) {
				if(!this.name.equals(temp.name))
					return false;
			} else {
				if(temp.name != null)
					return false;
			}

			//icon_uri must be considered for equality
			//for tests purposes:
			if(this.icon_uri != null) {
				if(!this.icon_uri.equals(temp.icon_uri))
					return false;
			} else {
				if(temp.icon_uri != null)
					return false;
			}			
			
			return true;

		}
		return false;
	}
	
	@Override
	public int hashCode() {		
		int result;
		result = _id == null? 0 : _id.hashCode();
		result += name == null? 0: name.hashCode();
		result += icon_uri == null? 0: icon_uri.hashCode();
		return result;
	}
	
}
